﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using ControleRepresentante.Logic.Models;
using WebSite.ViewModels.DetailsViewModels.DetailsGridViewModels;

namespace WebSite.ViewModels.DetailsViewModels
{
    public abstract class UsuariosHolderDetailsViewModel : DetailsHolderDetailsViewModel
    {
        public bool CanAddUser { get; set; }

        protected UsuariosHolderDetailsViewModel(string title) 
            : base(title)
        {
        }

        protected override IEnumerable<TabItem> GetTabs(HtmlHelper htmlHelper)
        {
            List<TabItem> result = base.GetTabs(htmlHelper).ToList();

            result.Add(new TabItem("Usuários",
                "~/Content/users.png",
                new UsuarioDetailsGridViewModel(htmlHelper, ((UsuariosHolder)Model).Users)));

            return result;
        }

        public override IEnumerable<ButtonType> AdditionalButtons
        {
            get
            {
                List<ButtonType> result = new List<ButtonType>(base.AdditionalButtons);
                if (CanAddUser)
                {
                    result.Add(ButtonType.AddUser);
                }
                return result;
            }
        }
    }
}